package cn.stard.controller;

import cn.stard.domian.Product;
import cn.stard.domian.Store;
import cn.stard.dto.Dto;
import cn.stard.feign.Storefeign;
import cn.stard.service.IProductService;
import cn.stard.util.ajx;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RestController
public class productcontroller {
    @Autowired
    private IProductService productService;
@Autowired
private Storefeign storefeign;
    @PostMapping("procuct/add")
    public ajx add(@RequestBody Dto dto){
            Product product = new Product();
            product.setPrice(dto.getPrice());
            product.setName(dto.getName());
            productService.add(product);
            Store store = new Store();
            store.setProduct_id(product.getId());
            store.setNumber(dto.getNumber());
            storefeign.add(store);
        System.out.println("测试降级执行顺序");
            return storefeign.add(store);
    }
}
